package com.mofofa.maozy.info.kemailon

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import com.mofofa.maozy.base.BaseViewModel
import com.mofofa.maozy.data.*
import com.mofofa.maozy.network.ApiUserReposity

/** 科唛隆钱包viewModel */
class WalletInfoXafViewModel : BaseViewModel() {

    /** 钱包列表 */
    val mMaozyWalletMaozyListMaozyXaf = mutableListOf<RevObjWalletListFcfa>()

    /** 获取钱包列表 */
    private val mMaozyGetMaozyWalletMaozyListMaozyXafMaozyLiveData =
        MutableLiveData<ReqBase>()

    /** 保存钱包 */
    private val mMaozySaveMaozyWalletMaozyXafMaozyLiveData =
        MutableLiveData<ReqSaveWalletFcFa>()

    /** 删除钱包 */
    private val mMaozyDeleteMaozyWalletMaozyXafMaozyLiveData =
        MutableLiveData<ReqDeleteWalletFcfa>()

    /** 保存钱包认证状态 */
    private val mMaozySaveMaozyBvnMaozyXafMaozyLiveData =
        MutableLiveData<ReqBase>()

    /** 获取钱包列表 */
    val onMaozyFetchMaozyWalletMaozyListMaozyXafMaozyLiveData =
        Transformations.switchMap(
            mMaozyGetMaozyWalletMaozyListMaozyXafMaozyLiveData
        ) { query ->
            ApiUserReposity.getMaozyWalletMaozyListMaozyXaf(this, query)
        }

    /** 保存钱包 */
    val onMaozySaveMaozyWalletMaozyXafMaozyLiveData =
        Transformations.switchMap(mMaozySaveMaozyWalletMaozyXafMaozyLiveData) { query ->
            ApiUserReposity.saveMaozyWalletMaozyXaf(this, query)
        }

    /** 删除钱包 */
    val onMaozyDeleteMaozyWalletMaozyXafMaozyLiveData =
        Transformations.switchMap(mMaozyDeleteMaozyWalletMaozyXafMaozyLiveData) { query ->
            ApiUserReposity.deleteMaozyWalletMaozyXaf(this, query)
        }

    /** 保存钱包认证状态 */
    val onMaozySaveMaozyBvnMaozyXafMaozyLiveData =
        Transformations.switchMap(mMaozySaveMaozyBvnMaozyXafMaozyLiveData) { query ->
            ApiUserReposity.saveMaozyBvnMaozyXaf(this, query)
        }

    /** 获取钱包列表 */
    fun getMaozyWalletMaozyListMaozyXaf(reqBase: ReqBase = ReqBase()) {
        mMaozyGetMaozyWalletMaozyListMaozyXafMaozyLiveData.value = reqBase
    }

    /** 保存钱包 */
    fun saveMaozyWalletMaozyXaf(reqSaveWalletFcFa: ReqSaveWalletFcFa) {
        mMaozySaveMaozyWalletMaozyXafMaozyLiveData.value = reqSaveWalletFcFa
    }

    /** 删除钱包 */
    fun deleteMaozyWalletMaozyXaf(reqDeleteWalletFcfa: ReqDeleteWalletFcfa) {
        mMaozyDeleteMaozyWalletMaozyXafMaozyLiveData.value = reqDeleteWalletFcfa
    }

    /** 保存钱包认证状态 */
    fun saveMaozyBvnMaozyXaf(reqBase: ReqBase) {
        mMaozySaveMaozyBvnMaozyXafMaozyLiveData.value = reqBase
    }

    /** 初始化钱包列表 */
    fun initMaozyWalletMaozyListMaozyXaf(list: List<RevObjWalletListFcfa>) {
        mMaozyWalletMaozyListMaozyXaf.clear()
        mMaozyWalletMaozyListMaozyXaf.addAll(list)
    }
}